package club.janna.concurrency.example.syncContainer;

import club.janna.concurrency.annotation.ThreadUnSafe;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Vector;

@Slf4j
@ThreadUnSafe
public class VectorExample2 {


    private static List<Integer> vector = new Vector<>();

    public static void main(String[] args) {
        while(true) {
            for (int i = 0; i < 10; i++) {
                vector.add(i);
            }

            new Thread(() -> {
                for (int i = 0; i < vector.size(); i++) {
                    vector.remove(i);
                }
            }).start();

            new Thread(() -> {
                for (int i = 0; i < vector.size(); i++) {
                    vector.get(i);
                }
            }).start();
        }
    }
}
